from typing import List
from sqlalchemy.orm import Mapped, relationship

from app.extensions import Base, INT_PK, STR_NOTNULL_UNIQUE_20

class Clas(Base):
    __tablename__ = "clases" # 表名
    id: Mapped[INT_PK]  # 主键id
    name: Mapped[STR_NOTNULL_UNIQUE_20] # 不允许重复

    studentsList: Mapped[List["Student"]] = relationship(back_populates="clas")

    def __repr__(self):
        return f"<Clas id:{self.id} name:{self.name}>"


if __name__ == '__main__':
    from app.extensions import engine
    Base.metadata.create_all(engine)